package com.uniflow.entity;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.util.StringUtils;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 数据同步实体类
 */
@ApiModel(description = "数据同步")
@TableName("data_sync")
public class DataSync {
    
    @ApiModelProperty("同步任务ID")
    @TableId(type = IdType.ASSIGN_ID)
    private String id;
    
    @ApiModelProperty("任务名称")
    private String name;
    
    @ApiModelProperty("任务描述")
    private String description;
    
    @ApiModelProperty("同步类型：import-导入，export-导出，sync-双向同步")
    private String type;
    
    @ApiModelProperty("数据源类型：database-数据库，api-API接口，file-文件，ftp-FTP")
    private String sourceType;
    
    @ApiModelProperty("数据源配置JSON")
    private String sourceConfigJson;
    
    @ApiModelProperty("目标类型：database-数据库，api-API接口，file-文件，ftp-FTP")
    private String targetType;
    
    @ApiModelProperty("目标配置JSON")
    private String targetConfigJson;
    
    @ApiModelProperty("映射配置JSON")
    private String mappingConfigJson;
    
    @ApiModelProperty("过滤条件JSON")
    private String filterConfigJson;
    
    @ApiModelProperty("转换规则JSON")
    private String transformConfigJson;
    
    @ApiModelProperty("调度配置JSON")
    private String scheduleConfigJson;
    
    @ApiModelProperty("同步状态：enabled-启用，disabled-禁用")
    private String status;
    
    @ApiModelProperty("执行状态：idle-空闲，running-运行中，success-成功，failed-失败")
    private String executeStatus;
    
    @ApiModelProperty("最后执行时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastExecuteTime;
    
    @ApiModelProperty("下次执行时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime nextExecuteTime;
    
    @ApiModelProperty("执行次数")
    private Integer executeCount;
    
    @ApiModelProperty("成功次数")
    private Integer successCount;
    
    @ApiModelProperty("失败次数")
    private Integer failureCount;
    
    @ApiModelProperty("最后执行结果")
    private String lastExecuteResult;
    
    @ApiModelProperty("最后错误信息")
    private String lastErrorMessage;
    
    @ApiModelProperty("执行耗时（毫秒）")
    private Long executeDuration;
    
    @ApiModelProperty("处理记录数")
    private Long processedRecords;
    
    @ApiModelProperty("成功记录数")
    private Long successRecords;
    
    @ApiModelProperty("失败记录数")
    private Long failureRecords;
    
    @ApiModelProperty("跳过记录数")
    private Long skippedRecords;
    
    @ApiModelProperty("优先级：1-最高，2-高，3-普通，4-低，5-最低")
    private Integer priority;
    
    @ApiModelProperty("超时时间（秒）")
    private Integer timeout;
    
    @ApiModelProperty("重试次数")
    private Integer retryCount;
    
    @ApiModelProperty("重试间隔（秒）")
    private Integer retryInterval;
    
    @ApiModelProperty("是否并行执行")
    private Boolean parallel;
    
    @ApiModelProperty("并行度")
    private Integer parallelism;
    
    @ApiModelProperty("批处理大小")
    private Integer batchSize;
    
    @ApiModelProperty("分类")
    private String category;
    
    @ApiModelProperty("标签")
    private String tags;
    
    @ApiModelProperty("备注")
    private String remark;
    
    @ApiModelProperty("扩展属性JSON")
    private String extendJson;
    
    @ApiModelProperty("排序")
    private Integer sort;
    
    @ApiModelProperty("是否删除")
    private Boolean deleted;
    
    @ApiModelProperty("版本号")
    private Integer version;
    
    @ApiModelProperty("租户ID")
    private String tenantId;
    
    @ApiModelProperty("创建人ID")
    private String createdBy;
    
    @ApiModelProperty("创建人姓名")
    private String createdByName;
    
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdTime;
    
    @ApiModelProperty("更新人ID")
    private String updatedBy;
    
    @ApiModelProperty("更新人姓名")
    private String updatedByName;
    
    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedTime;
    
    // 非数据库字段
    
    @ApiModelProperty("数据源配置")
    @TableField(exist = false)
    private Map<String, Object> sourceConfig;
    
    @ApiModelProperty("目标配置")
    @TableField(exist = false)
    private Map<String, Object> targetConfig;
    
    @ApiModelProperty("映射配置")
    @TableField(exist = false)
    private Map<String, Object> mappingConfig;
    
    @ApiModelProperty("过滤配置")
    @TableField(exist = false)
    private Map<String, Object> filterConfig;
    
    @ApiModelProperty("转换配置")
    @TableField(exist = false)
    private Map<String, Object> transformConfig;
    
    @ApiModelProperty("调度配置")
    @TableField(exist = false)
    private ScheduleConfig scheduleConfig;
    
    @ApiModelProperty("扩展属性")
    @TableField(exist = false)
    private Map<String, Object> extend;
    
    @ApiModelProperty("标签列表")
    @TableField(exist = false)
    private List<String> tagList;
    
    @ApiModelProperty("执行历史")
    @TableField(exist = false)
    private List<DataSyncLog> executeLogs;
    
    @ApiModelProperty("依赖任务列表")
    @TableField(exist = false)
    private List<String> dependencies;
    
    @ApiModelProperty("成功率")
    @TableField(exist = false)
    private Double successRate;
    
    @ApiModelProperty("平均执行时间")
    @TableField(exist = false)
    private Long avgExecuteDuration;
    
    @ApiModelProperty("是否可以执行")
    @TableField(exist = false)
    private Boolean canExecute;
    
    @ApiModelProperty("下次执行时间描述")
    @TableField(exist = false)
    private String nextExecuteTimeDesc;
    
    /**
     * 调度配置内部类
     */
    public static class ScheduleConfig {
        private String type; // cron, interval, once
        private String cronExpression;
        private Integer intervalSeconds;
        private LocalDateTime startTime;
        private LocalDateTime endTime;
        private Boolean enabled;
        
        // Getters and Setters
        public String getType() { return type; }
        public void setType(String type) { this.type = type; }
        public String getCronExpression() { return cronExpression; }
        public void setCronExpression(String cronExpression) { this.cronExpression = cronExpression; }
        public Integer getIntervalSeconds() { return intervalSeconds; }
        public void setIntervalSeconds(Integer intervalSeconds) { this.intervalSeconds = intervalSeconds; }
        public LocalDateTime getStartTime() { return startTime; }
        public void setStartTime(LocalDateTime startTime) { this.startTime = startTime; }
        public LocalDateTime getEndTime() { return endTime; }
        public void setEndTime(LocalDateTime endTime) { this.endTime = endTime; }
        public Boolean getEnabled() { return enabled; }
        public void setEnabled(Boolean enabled) { this.enabled = enabled; }
    }
    
    /**
     * 数据同步日志内部类
     */
    public static class DataSyncLog {
        private String id;
        private String syncId;
        private LocalDateTime startTime;
        private LocalDateTime endTime;
        private Long duration;
        private String status;
        private String result;
        private String errorMessage;
        private Long processedRecords;
        private Long successRecords;
        private Long failureRecords;
        private Long skippedRecords;
        
        // Getters and Setters
        public String getId() { return id; }
        public void setId(String id) { this.id = id; }
        public String getSyncId() { return syncId; }
        public void setSyncId(String syncId) { this.syncId = syncId; }
        public LocalDateTime getStartTime() { return startTime; }
        public void setStartTime(LocalDateTime startTime) { this.startTime = startTime; }
        public LocalDateTime getEndTime() { return endTime; }
        public void setEndTime(LocalDateTime endTime) { this.endTime = endTime; }
        public Long getDuration() { return duration; }
        public void setDuration(Long duration) { this.duration = duration; }
        public String getStatus() { return status; }
        public void setStatus(String status) { this.status = status; }
        public String getResult() { return result; }
        public void setResult(String result) { this.result = result; }
        public String getErrorMessage() { return errorMessage; }
        public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
        public Long getProcessedRecords() { return processedRecords; }
        public void setProcessedRecords(Long processedRecords) { this.processedRecords = processedRecords; }
        public Long getSuccessRecords() { return successRecords; }
        public void setSuccessRecords(Long successRecords) { this.successRecords = successRecords; }
        public Long getFailureRecords() { return failureRecords; }
        public void setFailureRecords(Long failureRecords) { this.failureRecords = failureRecords; }
        public Long getSkippedRecords() { return skippedRecords; }
        public void setSkippedRecords(Long skippedRecords) { this.skippedRecords = skippedRecords; }
    }
    
    // 业务方法
    
    /**
     * 是否启用
     */
    public boolean isEnabled() {
        return "enabled".equals(this.status);
    }
    
    /**
     * 是否已调度
     */
    public boolean isScheduled() {
        return scheduleConfig != null && scheduleConfig.getEnabled() != null && scheduleConfig.getEnabled();
    }
    
    /**
     * 获取调度配置对象
     */
    public ScheduleConfig getScheduleConfigObject() {
        return this.scheduleConfig;
    }
    
    /**
     * 获取执行状态
     */
    public String getExecutionStatus() {
        return this.executeStatus;
    }
    
    /**
     * 是否正在运行
     */
    public boolean isRunning() {
        return "running".equals(this.executeStatus);
    }
    
    /**
     * 是否执行成功
     */
    public boolean isSuccess() {
        return "success".equals(this.executeStatus);
    }
    
    /**
     * 是否执行失败
     */
    public boolean isFailed() {
        return "failed".equals(this.executeStatus);
    }
    
    /**
     * 获取成功率
     */
    public Double getSuccessRate() {
        if (executeCount == null || executeCount == 0) {
            return 0.0;
        }
        if (successCount == null) {
            return 0.0;
        }
        return (double) successCount / executeCount * 100;
    }
    
    /**
     * 获取失败率
     */
    public Double getFailureRate() {
        if (executeCount == null || executeCount == 0) {
            return 0.0;
        }
        if (failureCount == null) {
            return 0.0;
        }
        return (double) failureCount / executeCount * 100;
    }
    
    /**
     * 获取优先级描述
     */
    public String getPriorityDesc() {
        if (priority == null) {
            return "普通";
        }
        switch (priority) {
            case 1: return "最高";
            case 2: return "高";
            case 3: return "普通";
            case 4: return "低";
            case 5: return "最低";
            default: return "普通";
        }
    }
    
    /**
     * 获取状态描述
     */
    public String getStatusDesc() {
        if (status == null) {
            return "未知";
        }
        switch (status) {
            case "enabled": return "启用";
            case "disabled": return "禁用";
            default: return "未知";
        }
    }
    
    /**
     * 获取执行状态描述
     */
    public String getExecuteStatusDesc() {
        if (executeStatus == null) {
            return "未知";
        }
        switch (executeStatus) {
            case "idle": return "空闲";
            case "running": return "运行中";
            case "success": return "成功";
            case "failed": return "失败";
            default: return "未知";
        }
    }
    
    /**
     * 获取类型描述
     */
    public String getTypeDesc() {
        if (type == null) {
            return "未知";
        }
        switch (type) {
            case "import": return "导入";
            case "export": return "导出";
            case "sync": return "双向同步";
            default: return "未知";
        }
    }
    
    /**
     * 获取数据源类型描述
     */
    public String getSourceTypeDesc() {
        return getDataSourceTypeDesc(sourceType);
    }
    
    /**
     * 获取目标类型描述
     */
    public String getTargetTypeDesc() {
        return getDataSourceTypeDesc(targetType);
    }
    
    /**
     * 获取数据源类型描述
     */
    private String getDataSourceTypeDesc(String dataSourceType) {
        if (dataSourceType == null) {
            return "未知";
        }
        switch (dataSourceType) {
            case "database": return "数据库";
            case "api": return "API接口";
            case "file": return "文件";
            case "ftp": return "FTP";
            default: return "未知";
        }
    }
    
    /**
     * 格式化执行时间
     */
    public String formatExecuteDuration() {
        if (executeDuration == null) {
            return "0秒";
        }
        
        long seconds = executeDuration / 1000;
        if (seconds < 60) {
            return seconds + "秒";
        }
        
        long minutes = seconds / 60;
        seconds = seconds % 60;
        if (minutes < 60) {
            return minutes + "分" + (seconds > 0 ? seconds + "秒" : "");
        }
        
        long hours = minutes / 60;
        minutes = minutes % 60;
        return hours + "小时" + (minutes > 0 ? minutes + "分" : "") + (seconds > 0 ? seconds + "秒" : "");
    }
    
    // Getters and Setters
    
    public String getId() { return id; }
    public void setId(String id) { this.id = id; }
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    public String getDescription() { return description; }
    public void setDescription(String description) { this.description = description; }
    public String getType() { return type; }
    public void setType(String type) { this.type = type; }
    public String getSourceType() { return sourceType; }
    public void setSourceType(String sourceType) { this.sourceType = sourceType; }
    public String getSourceConfigJson() { return sourceConfigJson; }
    public void setSourceConfigJson(String sourceConfigJson) { this.sourceConfigJson = sourceConfigJson; }
    public String getTargetType() { return targetType; }
    public void setTargetType(String targetType) { this.targetType = targetType; }
    public String getTargetConfigJson() { return targetConfigJson; }
    public void setTargetConfigJson(String targetConfigJson) { this.targetConfigJson = targetConfigJson; }
    public String getMappingConfigJson() { return mappingConfigJson; }
    public void setMappingConfigJson(String mappingConfigJson) { this.mappingConfigJson = mappingConfigJson; }
    public String getFilterConfigJson() { return filterConfigJson; }
    public void setFilterConfigJson(String filterConfigJson) { this.filterConfigJson = filterConfigJson; }
    public String getTransformConfigJson() { return transformConfigJson; }
    public void setTransformConfigJson(String transformConfigJson) { this.transformConfigJson = transformConfigJson; }
    public String getScheduleConfigJson() { return scheduleConfigJson; }
    public void setScheduleConfigJson(String scheduleConfigJson) { this.scheduleConfigJson = scheduleConfigJson; }
    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }
    public String getExecuteStatus() { return executeStatus; }
    public void setExecuteStatus(String executeStatus) { this.executeStatus = executeStatus; }
    public LocalDateTime getLastExecuteTime() { return lastExecuteTime; }
    public void setLastExecuteTime(LocalDateTime lastExecuteTime) { this.lastExecuteTime = lastExecuteTime; }
    public LocalDateTime getNextExecuteTime() { return nextExecuteTime; }
    public void setNextExecuteTime(LocalDateTime nextExecuteTime) { this.nextExecuteTime = nextExecuteTime; }
    public Integer getExecuteCount() { return executeCount; }
    public void setExecuteCount(Integer executeCount) { this.executeCount = executeCount; }
    public Integer getSuccessCount() { return successCount; }
    public void setSuccessCount(Integer successCount) { this.successCount = successCount; }
    public Integer getFailureCount() { return failureCount; }
    public void setFailureCount(Integer failureCount) { this.failureCount = failureCount; }
    public String getLastExecuteResult() { return lastExecuteResult; }
    public void setLastExecuteResult(String lastExecuteResult) { this.lastExecuteResult = lastExecuteResult; }
    public String getLastErrorMessage() { return lastErrorMessage; }
    public void setLastErrorMessage(String lastErrorMessage) { this.lastErrorMessage = lastErrorMessage; }
    public Long getExecuteDuration() { return executeDuration; }
    public void setExecuteDuration(Long executeDuration) { this.executeDuration = executeDuration; }
    public Long getProcessedRecords() { return processedRecords; }
    public void setProcessedRecords(Long processedRecords) { this.processedRecords = processedRecords; }
    public Long getSuccessRecords() { return successRecords; }
    public void setSuccessRecords(Long successRecords) { this.successRecords = successRecords; }
    public Long getFailureRecords() { return failureRecords; }
    public void setFailureRecords(Long failureRecords) { this.failureRecords = failureRecords; }
    public Long getSkippedRecords() { return skippedRecords; }
    public void setSkippedRecords(Long skippedRecords) { this.skippedRecords = skippedRecords; }
    public Integer getPriority() { return priority; }
    public void setPriority(Integer priority) { this.priority = priority; }
    public Integer getTimeout() { return timeout; }
    public void setTimeout(Integer timeout) { this.timeout = timeout; }
    public Integer getRetryCount() { return retryCount; }
    public void setRetryCount(Integer retryCount) { this.retryCount = retryCount; }
    public Integer getRetryInterval() { return retryInterval; }
    public void setRetryInterval(Integer retryInterval) { this.retryInterval = retryInterval; }
    public Boolean getParallel() { return parallel; }
    public void setParallel(Boolean parallel) { this.parallel = parallel; }
    public Integer getParallelism() { return parallelism; }
    public void setParallelism(Integer parallelism) { this.parallelism = parallelism; }
    public Integer getBatchSize() { return batchSize; }
    public void setBatchSize(Integer batchSize) { this.batchSize = batchSize; }
    public String getCategory() { return category; }
    public void setCategory(String category) { this.category = category; }
    public String getTags() { return tags; }
    public void setTags(String tags) { this.tags = tags; }
    public String getRemark() { return remark; }
    public void setRemark(String remark) { this.remark = remark; }
    public String getExtendJson() { return extendJson; }
    public void setExtendJson(String extendJson) { this.extendJson = extendJson; }
    public Integer getSort() { return sort; }
    public void setSort(Integer sort) { this.sort = sort; }
    public Boolean getDeleted() { return deleted; }
    public void setDeleted(Boolean deleted) { this.deleted = deleted; }
    public Integer getVersion() { return version; }
    public void setVersion(Integer version) { this.version = version; }
    public String getTenantId() { return tenantId; }
    public void setTenantId(String tenantId) { this.tenantId = tenantId; }
    public String getCreatedBy() { return createdBy; }
    public void setCreatedBy(String createdBy) { this.createdBy = createdBy; }
    public String getCreatedByName() { return createdByName; }
    public void setCreatedByName(String createdByName) { this.createdByName = createdByName; }
    public LocalDateTime getCreatedTime() { return createdTime; }
    public void setCreatedTime(LocalDateTime createdTime) { this.createdTime = createdTime; }
    public String getUpdatedBy() { return updatedBy; }
    public void setUpdatedBy(String updatedBy) { this.updatedBy = updatedBy; }
    public String getUpdatedByName() { return updatedByName; }
    public void setUpdatedByName(String updatedByName) { this.updatedByName = updatedByName; }
    public LocalDateTime getUpdatedTime() { return updatedTime; }
    public void setUpdatedTime(LocalDateTime updatedTime) { this.updatedTime = updatedTime; }
    public Map<String, Object> getSourceConfig() { return sourceConfig; }
    public void setSourceConfig(Map<String, Object> sourceConfig) { this.sourceConfig = sourceConfig; }
    public Map<String, Object> getTargetConfig() { return targetConfig; }
    public void setTargetConfig(Map<String, Object> targetConfig) { this.targetConfig = targetConfig; }
    public Map<String, Object> getMappingConfig() { return mappingConfig; }
    public void setMappingConfig(Map<String, Object> mappingConfig) { this.mappingConfig = mappingConfig; }
    public Map<String, Object> getFilterConfig() { return filterConfig; }
    public void setFilterConfig(Map<String, Object> filterConfig) { this.filterConfig = filterConfig; }
    public Map<String, Object> getTransformConfig() { return transformConfig; }
    public void setTransformConfig(Map<String, Object> transformConfig) { this.transformConfig = transformConfig; }
    public ScheduleConfig getScheduleConfig() { return scheduleConfig; }
    public void setScheduleConfig(ScheduleConfig scheduleConfig) { this.scheduleConfig = scheduleConfig; }
    public Map<String, Object> getExtend() { return extend; }
    public void setExtend(Map<String, Object> extend) { this.extend = extend; }
    public List<String> getTagList() { return tagList; }
    public void setTagList(List<String> tagList) { this.tagList = tagList; }
    public List<DataSyncLog> getExecuteLogs() { return executeLogs; }
    public void setExecuteLogs(List<DataSyncLog> executeLogs) { this.executeLogs = executeLogs; }
    public List<String> getDependencies() { return dependencies; }
    public void setDependencies(List<String> dependencies) { this.dependencies = dependencies; }
    public void setSuccessRate(Double successRate) { this.successRate = successRate; }
    public Long getAvgExecuteDuration() { return avgExecuteDuration; }
    public void setAvgExecuteDuration(Long avgExecuteDuration) { this.avgExecuteDuration = avgExecuteDuration; }
    public Boolean getCanExecute() { return canExecute; }
    public void setCanExecute(Boolean canExecute) { this.canExecute = canExecute; }
    public String getNextExecuteTimeDesc() { return nextExecuteTimeDesc; }
    public void setNextExecuteTimeDesc(String nextExecuteTimeDesc) { this.nextExecuteTimeDesc = nextExecuteTimeDesc; }
    
    // 添加缺失的方法
    public String getExtendedPropertiesJson() { return extendJson; }
    public void setTagsList(List<String> tagsList) { this.tagList = tagsList; }
    public void setFailureRate(Double failureRate) { /* 计算属性，不需要setter */ }
    public Long getAvgExecutionTime() { return avgExecuteDuration; }
    public boolean isExecutable() { return canExecute != null ? canExecute : false; }
    public String getNextExecutionTimeDesc() { return nextExecuteTimeDesc; }
    
    // 添加更多缺失的setter方法
    public void setTransformConfigObj(Map<String, Object> transformConfigObj) { this.transformConfig = transformConfigObj; }
    public void setScheduleConfigObj(ScheduleConfig scheduleConfigObj) { this.scheduleConfig = scheduleConfigObj; }
    public void setExtendedPropertiesObj(Map<String, Object> extendedPropertiesObj) { this.extend = extendedPropertiesObj; }
    public void setAvgExecutionTime(Long avgExecutionTime) { this.avgExecuteDuration = avgExecutionTime; }
    public void setExecutable(boolean executable) { this.canExecute = executable; }
    public void setNextExecutionTimeDesc(String nextExecutionTimeDesc) { this.nextExecuteTimeDesc = nextExecutionTimeDesc; }
    
    // 添加更多缺失的方法
    public List<String> getTagsList() { return tagList; }
    public void setSourceConfigObj(Map<String, Object> sourceConfigObj) { this.sourceConfig = sourceConfigObj; }
    public void setTargetConfigObj(Map<String, Object> targetConfigObj) { this.targetConfig = targetConfigObj; }
    public void setMappingConfigObj(Map<String, Object> mappingConfigObj) { this.mappingConfig = mappingConfigObj; }
    public void setFilterConfigObj(Map<String, Object> filterConfigObj) { this.filterConfig = filterConfigObj; }
    
    // 添加更多缺失的getter方法
    public Map<String, Object> getSourceConfigObj() { return sourceConfig; }
    public Map<String, Object> getTargetConfigObj() { return targetConfig; }
    public Map<String, Object> getMappingConfigObj() { return mappingConfig; }
    public Map<String, Object> getFilterConfigObj() { return filterConfig; }
    public Map<String, Object> getTransformConfigObj() { return transformConfig; }
    public ScheduleConfig getScheduleConfigObj() { return scheduleConfig; }
    public Map<String, Object> getExtendedPropertiesObj() { return extend; }
    
    // 添加更多缺失的方法
    public void setExecutionStatus(String executionStatus) { this.executeStatus = executionStatus; }
    public Integer getParallelCount() { return parallelism; }
    public void setParallelCount(int parallelCount) { this.parallelism = parallelCount; }
    public String getSyncType() { return type; }
    public void setSyncType(String syncType) { this.type = syncType; }
    public Map<String, Object> getExtendedProperties() { return extend; }
    public void setExtendedProperties(Map<String, Object> extendedProperties) { this.extend = extendedProperties; }
    public void setExtendedPropertiesJson(String extendedPropertiesJson) { this.extendJson = extendedPropertiesJson; }
    public Map<String, Object> getExecutionStatsObject() {
        Map<String, Object> stats = new HashMap<>();
        stats.put("executeCount", executeCount);
        stats.put("successCount", successCount);
        stats.put("failureCount", failureCount);
        stats.put("lastExecuteTime", lastExecuteTime);
        stats.put("executeDuration", executeDuration);
        return stats;
    }
    
    /**
     * 获取同步配置对象
     */
    public Map<String, Object> getSyncConfigObject() {
        if (StringUtils.hasText(this.extendJson)) {
            try {
                // 使用简单的Map替代JSONObject
                return new HashMap<>();
            } catch (Exception e) {
                return new HashMap<>();
            }
        }
        return new HashMap<>();
    }
    
    /**
     * 设置最后执行时间
     */
    public void setLastExecutionTime(LocalDateTime lastExecutionTime) {
        this.lastExecuteTime = lastExecutionTime;
    }
    
    /**
     * 设置最后执行状态
     */
    public void setLastExecutionStatus(String lastExecutionStatus) {
        this.executeStatus = lastExecutionStatus;
    }
    
    /**
     * 设置最后执行错误
     */
    public void setLastExecutionError(String lastExecutionError) {
        this.lastErrorMessage = lastExecutionError;
    }
}